/**
 * @author: Administrative Attributes
 * @author: YoungYa
 * @date: 2024-10-27 10:12:33
 */
import { ACCESS_TYPE, FILE_TYPE } from '@/utils/enums';
import type { AnnouncementTypes, CommonTypes, Flag, OrgTypes, Times } from '@/utils/types';
import { EnumValues } from '@/utils/types';

import { UserAttributes } from './system';

/**
 * @description: xmw_organization Attributes
 * @author: YoungYa
 */
export type OrgAttributes = {
  org_id: string; // 组织id
  org_name: string; // 组织名称
  org_code: string; // 组织编码
  org_type: OrgTypes; // 组织类型
  children?: OrgAttributes[];
} & Times &
  CommonTypes;

/**
 * @description: xmw_jobs Attributes
 * @author: YoungYa
 */
export type JobsAttributes = {
  jobs_id: string; // 岗位id
  jobs_name: string; // 岗位名称
  children?: JobsAttributes[];
} & Times &
  Pick<OrgAttributes, 'org_id'> &
  Omit<CommonTypes, 'status'>;

/**
 * @description: xmw_announcement Attributes
 * @author: YoungYa
 */
export type AnnouncementAttributes = {
  announcement_id: string; // id 主键
  title: string; // 标题
  content: string; // 正文内容
  type: AnnouncementTypes; // 类型
  pinned: Flag; // 是否置顶
} & Times &
  Pick<UserAttributes, 'user_id'> &
  Pick<CommonTypes, 'status'>;

/**
 * @description: xmw_already Attributes
 * @author: YoungYa
 */
export type AlreadyAttributes = {
  id: string; // id 主键
} & Times &
  Pick<UserAttributes, 'user_id'> &
  Pick<AnnouncementAttributes, 'announcement_id'>;

export type FileCollectionAttributes = {
  task_id: string; // 任务id
  title: string; // 标题
  content: string; // 内容要求
  // file_type: FileType[]; // 文件类型
  file_type: string; // 文件类型
  access: AccessType; // 任务提交的访问权限
  access_pwd?: string; // 任务提交的访问密码
  submitter?: string[]; // 指定人员
  reviewer_id: string; // 审核人id
  review_time: Date; // 审核时间
  end_time: Date; // 截止时间
  founder_id: string; // 创建人id
  status: number; // 状态
  pinned: Flag; // 是否置顶
} & Times;

/**
 * @description: Submitter Attributes
 */
export type SubmitterAttributes = {
  id: string; // id 主键
  user_id: string; // 用户id
  file_path: string; // 文件id
  file_type: FileType; // 文件类型
  submit_time: Date; // 提交时间
  status: number; // 状态
} & Times &
  Pick<UserAttributes, 'user_name'> &
  Pick<FileCollectionAttributes, 'task_id'>;

/**
 * @description: 枚举访问类型
 * @author: YoungYa
 */
export type AccessType = EnumValues<typeof ACCESS_TYPE>;

/**
 * @description: 枚举文件类型
 * @author: YoungYa
 */
export type FileType = EnumValues<typeof FILE_TYPE>;
